<template>
  <div>
    <Dog v-for="(obj, index) in arr"
    :key="index"
    :imgurl="obj.dogImgUrl"
    :dogname="obj.dogName"
     @love="loveFn"
    ></Dog>
    <div>你喜欢的狗如下：
      <ul>
        <li v-for="(item,index) in newArr" :key="index">{{item}}</li>
      </ul>
    </div>
  </div> 
</template>

<script>
import Dog from './components/Dog4'
export default {
  data() {
    return {
      // 1. 准备数据
      arr: [
    {
        dogImgUrl:
        "http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg",
        dogName: "博美",
    },
    {
        dogImgUrl:
        "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1224576619,1307855467&fm=26&gp=0.jpg",
        dogName: "泰迪",
    },
    {
        dogImgUrl:
        "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2967740259,1518632757&fm=26&gp=0.jpg",
        dogName: "金毛",
    },
    {
        dogImgUrl:
        "https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c",
        dogName: "哈士奇",
    },
    {
        dogImgUrl:
        "https://img2.baidu.com/it/u=168687451,714454099&fm=26&fmt=auto&gp=0.jpg",
        dogName: "阿拉斯加",
    },
    {
        dogImgUrl:
        "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Feuro-premium.cn%2Fsites%2Fdefault%2Ffiles%2F2018%2F03%2F2018-03-02-602.jpg&refer=http%3A%2F%2Feuro-premium.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1621220024&t=9895ceb3906303f7be5ec85d632c1128",
        dogName: "萨摩耶",
    },
],
      newArr:[]
    };
  },
  components: {
    Dog
  },
  methods:{
    loveFn(dogName){
      this.newArr.push(dogName)
    }
  }
};
</script>
<style>
    li {
      list-style: none;
    }
</style>